package com.manager.common.tcp.watch;

import com.manager.common.tcp.client.TcpClient;
import com.manager.common.utils.DataTools;

/**
 * @ClassName TcpClientWatchDog
 * @Description TODO
 * @Author @LiuHongJun
 * @Date 2025-09-29 9:22
 * @Version 1.0
 */
public class TcpClientWatchDog extends Thread{

    private String ip;

    private int port;

    public TcpClientWatchDog(String ip, int port){
        this.ip = ip;
        this.port = port;
    }

    @Override
    public void run() {
        while (true){
            try {
                try {
                    Thread.sleep(10000);
                }catch (Exception e){

                }
                System.out.println("tcpClientWatchDog：" + DataTools.hasTcpConnected());
                if(!DataTools.hasTcpConnected()){
                    TcpClient.getInstance().connect(ip,port);
                }
            }catch (Exception e){
                e.printStackTrace();
            }finally {

            }
        }
    }
}
